home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Dr. Windows 3
/
dr win3.zip
/
dr win3
/
WINPROGS
/
CDSOUND.ZIP
/
SOURCE.ZIP
/
SOUNDOFF.C
< prev
next >
Wrap
C/C++ Source or Header
|
1993-07-24
|
23KB
|
646 lines
/***************************************************************************/
/* CD SOUND OFF */
/***************************************************************************/
/*
CD SoundOff is an audio CD player that is provided for your enjoyment.
If you like CD SoundOff, feel free to show me by helping with the
development costs. Any and all donations will be greatly appreciated.
CD SoundOff is provided as is with the C source code. This software was
developed using the Microsoft Windows 3.1 SDK and Microsoft C 7.0. Feel free
to add your own enhancements to CD SoundOff and please send me a copy
so that I can keep up with all of the new and exciting CD bells and
whistles.
NickleWare
P.O. Box 393
Orem, UT. 84059
NickleWare
CompuServe: 72730,1002
Copyright (C) 93 Bradley Nicholes
This documentation must accompany the CD SoundOff software.
NickleWare or Bradley Nicholes shall not be liable for any damages, whether
direct, indirect, special or consequential arising from the use or failure
of this program to operate in the manner desired by the user.
*/
/***************************************************************************/
/* I N C L U D E F I L E S */
/***************************************************************************/
#define NOGDICAPMASKS
#define NOVIRTUALKEYCODES
#define NONCMESSAGES
#define NODRAWFRAME
#define NOKEYSTATE
#define NORASTEROPS
#include <WINDOWS.H>
#include <mmsystem.h>
#include "soundoff.h"
#include <stdlib.h>
#include <string.h>
/***************************************************************************/
/* T H E P R O G R A M ' S G L O B A L V A R I A B L E S */
/***************************************************************************/
HINSTANCE hInst;
/***************************************************************************/
/* FORWARD REFERENCES */
/***************************************************************************/
BOOL CALLBACK SoundOffDlgProc (HWND, UINT, WPARAM, LPARAM);
BOOL CALLBACK AboutboxWindowProc (HWND, UINT, WPARAM, LPARAM);
/***************************************************************************/
/* M A I N P R O G R A M */
/***************************************************************************/
int FAR PASCAL WinMain (hInstance, hPrevInstance, lpszCmdLine, cmdShow)
HANDLE hInstance, hPrevInstance;
LPSTR lpszCmdLine; /* Length of the command line. */
int cmdShow; /* Iconic or Tiled when start. */
{
FARPROC lpprocSoundOff;
HWND hwndDlg;
MSG msg;
hInst = hInstance;
// Create the main dialog window as a modeless dialog.
lpprocSoundOff = (FARPROC)MakeProcInstance( SoundOffDlgProc, hInstance);
hwndDlg = CreateDialog (hInstance, "SoundOffDlg", GetDesktopWindow(),
lpprocSoundOff);
// If the dialog was created correctly then contine to the main message
// loop. Otherwise exit the program.
if (hwndDlg == 0)
return 1;
while (GetMessage(&msg, NULL, 0, 0)) /* The main loop: */
{ /* (terminated by a QUIT) */
if (!IsDialogMessage(hwndDlg, &msg))
{
TranslateMessage(&msg); /* Have Windows translate */
DispatchMessage(&msg); /* Have Windows give message */
} /* to the window proc. */
}
// Destroy the dialog and exit the program.
DestroyWindow (hwndDlg);
FreeProcInstance ( lpprocSoundOff);
return(0);
}
/***************************************************************************/
/* T H E A B O U T B O X H A N D L I N G P R O C E D U R E */
/***************************************************************************/
/* This is the window procedure for the main CD SoundOff control panel. */
BOOL CALLBACK SoundOffDlgProc (HWND hDlg, UINT message, WPARAM wParam,
LPARAM lParam)
{
DRAWITEMSTRUCT FAR *pDrawItem; // Passed in from the WM_DRAWITEM message.
HICON hIcon; // Button Icon.
char szBuffer[128]; // CD Audio command buffer.
char szReturn[128]; // CD Audio return buffer.
static BOOL bContinuous = FALSE; // Auto-Repeat flag.
static BOOL bPlay = FALSE; // CD Audio currently playing flag.
static BOOL bPause = FALSE; // CD Audio currently paused flag.
static WORD wTracks; // Total number of tracks.
static WORD wCurrTrack; // Currently playing track.
static HICON hTrackIcon; // Track icon.
HICON hOldIcon; // Previous track icon.
PAINTSTRUCT ps; // Paint structure.
RECT rc; // Window rectangle structure.
HMENU hSysMenu; // System menu.
FARPROC lpprocAbout; // About dialog proc.
switch (message ) {
case WM_INITDIALOG:
// Open the cdaudio device to query the current status.
mciSendString("open cdaudio", NULL, 0, hDlg);
// Set the cdaudio device time format.
mciSendString("set cdaudio time format tmsf", NULL, 0, hDlg);
// Query the current state of the device.
mciSendString("status cdaudio mode", szReturn, sizeof(szReturn),
hDlg);
// If the cdaudio device is playing then initiallize the status
// to the current state.
if (_stricmp (szReturn, "playing") == 0) {
bPlay = TRUE;
// Tell the device to notify the dialog of any events.
mciSendString("play cdaudio notify", NULL, 0, hDlg);
// Start the status polling timer.
SetTimer(hDlg, CD_TIMER, 500, NULL);
}
// If the cdaudio device is paused then initialize the status to
// the current state.
if (_stricmp (szReturn, "paused") == 0) {
bPause = TRUE;
}
// Load and display the default track indicator icon.
hTrackIcon = LoadIcon (hInst, "NONE");
// Add the control panel commands to the system menu.
hSysMenu = GetSystemMenu (hDlg, FALSE);
AppendMenu (hSysMenu, MF_SEPARATOR, 0, NULL);
AppendMenu (hSysMenu, MF_STRING, IDB_PREVIOUS, "Pre&vious");
AppendMenu (hSysMenu, MF_STRING, IDB_PLAY, "&Play");
AppendMenu (hSysMenu, MF_STRING, IDB_PAUSE, "P&ause");
AppendMenu (hSysMenu, MF_STRING, IDB_STOP, "S&top");
AppendMenu (hSysMenu, MF_STRING, IDB_NEXT, "&Next");
AppendMenu (hSysMenu, MF_STRING, IDB_CONTINUOUS, "A&uto-Repeat");
AppendMenu (hSysMenu, MF_SEPARATOR, 0, NULL);
AppendMenu (hSysMenu, MF_STRING, IDM_ABOUT, "About!");
return TRUE;
case WM_TIMER:
// Query the cdaudio device for the current track.
mciSendString("status cdaudio current track", szReturn,
sizeof(szReturn), hDlg);
// If the current track has changed then update the display.
if (wCurrTrack != (WORD)atoi(szReturn)) {
wCurrTrack = atoi(szReturn);
// Load and display the new track display icon.
switch (wCurrTrack) {
case 0:
hTrackIcon = LoadIcon (hInst, "NONE");
break;
case 1:
hTrackIcon = LoadIcon (hInst, "ONE");
break;
case 2:
hTrackIcon = LoadIcon (hInst, "TWO");
break;
case 3:
hTrackIcon = LoadIcon (hInst, "THREE");
break;